Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding projects created for content about hybrid search for an ecommerce #343

Conversation

andreluiz1987
Copy link
Contributor

This PR contains the frontend and api projects built for the article How to use Hybrid search for an e-commerce product catalogue

Copy link

gitnotebooks bot commented Oct 22, 2024

Found 1 changed notebook. Review the changes at https://app.gitnotebooks.com/elastic/elasticsearch-labs/pull/343

Copy link
Contributor

@carlyrichmond carlyrichmond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've suggested a few minor code styling considerations. Logic-wise it appears fine.

const defaultImage = "https://via.placeholder.com/100";

const handleClick = () => {
//alert(`Produto: ${product.name} - Termo de pesquisa: ${searchTerm}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//alert(`Produto: ${product.name} - Termo de pesquisa: ${searchTerm}`);

Can we remove the commented out alert since it's not used.

query: searchTerm,
selectedCategories: selectedFacets.categories,
selectedProductTypes: selectedFacets.productTypes,
selectedbrands: selectedFacets.brands,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
selectedbrands: selectedFacets.brands,
selectedBrands: selectedFacets.brands,

query: searchTerm,
selectedCategories: selectedFacets.categories,
selectedProductTypes: selectedFacets.productTypes,
selectedbrands: selectedFacets.brands,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
selectedbrands: selectedFacets.brands,
selectedBrands: selectedFacets.brands,


## Referências

- [Documentação do Docker](https://docs.docker.com/)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [Documentação do Docker](https://docs.docker.com/)
- [Docker Documentation](https://docs.docker.com/)

## Referências

- [Documentação do Docker](https://docs.docker.com/)
- [Documentação do Docker Compose](https://docs.docker.com/compose/)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [Documentação do Docker Compose](https://docs.docker.com/compose/)
- [Docker Compose Documentation](https://docs.docker.com/compose/)



if __name__ == '__main__':
# print(get_client_es().info())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# print(get_client_es().info())


vector = get_text_vector([term])[0]

# Query híbrida com RRF (Reciprocal Rank Fusion)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Query híbrida com RRF (Reciprocal Rank Fusion)
# Hybrid query with RRF (Reciprocal Rank Fusion)



def build_hybrid_query(term=None, categories=None, product_types=None, brands=None, hybrid=False):
# Query padrão
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Query padrão
# Standard query

Copy link
Contributor

@carlyrichmond carlyrichmond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good! I've spotted a few Portuguese comments that have been missed. I've added comments to the relevant files where I've seen them.

@andreluiz1987 do you mind checking the project once more to make sure those are translated?

}
};

// Função para buscar os facets
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you translate this comment please?

@@ -0,0 +1,34 @@
# Arquivos de configuração local
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you translate the comments to English for consistency please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I translated the other files from Portuguese to English.

@carlyrichmond carlyrichmond merged commit d968b49 into elastic:main Nov 12, 2024
1 check passed
@carlyrichmond
Copy link
Contributor

@andreluiz1987 I think your changes have some issues. Can you check that you've run the pre-commit steps and raise a PR for those?

python -m venv .venv
.venv/bin/pip install -qqq -r requirements-dev.txt
.venv/bin/pre-commit install

@chungwong
Copy link

This PR has mulitple issues and at least one issue is common to other PR as well.

In addition to the wrong path for https://github.com/elastic/elasticsearch-labs/blob/main/supporting-blog-content/hybrid-search-for-an-e-commerce-product-catalogue/product-store-search/ingestion/ingestion.py#L49, I have to upgrade sentence-transformers upgrade to 3.3.0, otherwise it won't work with hugging face.

# Hybrid query with RRF (Reciprocal Rank Fusion)
query = {
"retriever": {
"rrf": {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andreluiz1987 thanks for your post and contribution! it was great!
What are the consideration for chosing rrf over a simple should?
Do you get the same score range with rrf? (knn return _score between 0-1.0 and organic_query doesn't have an upper _score bound)

I asked in the forum but I wondered if you have the same issue here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants